<?php
use yii\helpers\Html;
use \backend\controllers\DtActionFilter;
$project_id = Yii::$app->request->get("project_id");

if (!empty($project_id)){
    $isView = DtActionFilter::checkProject('project_edit',$project_id);
}else{
    $isView=true;
    return '无用户id';
}
?>
<div class="container containerShadow">
    <div class="row">
        <div class="topimg">
            <div class="left pull-left">
                <span>司法进展</span>
            </div>
            <div class="pull-right">
                <a href="javascript:;">
                    <?php
                    if ($isView){
                        echo Html::img("/image/projectDetails/edit.png",["id"=>"getJudicial","data-val"=>2]);
                    }
                    ?>
                </a>
            </div>
        </div>
        <form action="" class="judicialW">
             <?= empty($Lawsuit['judgement'])&&empty($Lawsuit['execution'])&&empty($Lawsuit['judcourtment'])&&empty($Lawsuit['block'])?'<p class="text-left">暂无数据</p>':'';?>
            <table class="tableRaius" border="0" cellspacing="0" cellpadding="0" style="border-collapse:separate;border-spacing: 0; <?= empty($Lawsuit['judgement'])&&empty($Lawsuit['execution'])&&empty($Lawsuit['court'])&&empty($Lawsuit['block'])?'display:none':'';?>">
                <tr>
                    <td>判&nbsp;&nbsp;决</td>
                    <td>
                    	<pre><?= !empty($Lawsuit['judgement'])?$Lawsuit['judgement']:'';?></pre>
                      <!--  <input type="text" readonly="readonly" name="" id="" title="判&nbsp;&nbsp;决" value="<?= !empty($Lawsuit['judgement'])?$Lawsuit['judgement']:'';?>" />-->
                    </td>
                </tr>
                <tr>
                    <td>执&nbsp;&nbsp;行</td>
                    <td>
                    	<pre><?= !empty($Lawsuit['execution'])?$Lawsuit['execution']:'';?></pre>
                       <!-- <input type="text" readonly="readonly" name="" id="" title="执&nbsp;&nbsp;行" value="<?= !empty($Lawsuit['execution'])?$Lawsuit['execution']:'';?>" />-->
                    </td>
                </tr>
                <tr>
                    <td>法&nbsp;&nbsp;院</td>
                    <td>
                    	<pre><?= !empty($Lawsuit['court'])?$Lawsuit['court']:'';?></pre>
                       <!-- <input type="text" readonly="readonly" name="" id="" title="法&nbsp;&nbsp;院" value="<?= !empty($Lawsuit['court'])?$Lawsuit['court']:'';?>" />-->
                    </td>
                </tr>
                <tr>
                    <td>列失信</td>
                    <td>
                    	<pre><?= !empty($Lawsuit['block'])?$Lawsuit['block']:'';?></pre>
                       <!-- <input type="text" readonly="readonly" name="" id="" title="列失信" value="<?= !empty($Lawsuit['block'])?$Lawsuit['block']:'';?>" />-->
                    </td>
                </tr>
            </table>

        </form>

        <form action="" class="judicialEdit" style="display: none;">
            <table class="tableRaius editTable " border="0" cellspacing="0" cellpadding="0" style="border-collapse:separate;border-spacing: 0;border: none;">
                <tr>
                    <td>判&nbsp;&nbsp;决</td>
                    <td>
                        <textarea name="" class="textarea-edit" rows="" cols="" id="judgement"><?= !empty($Lawsuit['judgement'])?$Lawsuit['judgement']:'';?></textarea>
                    </td>
                </tr>
                <tr>
                    <td>执&nbsp;&nbsp;行</td>
                    <td>
                        <textarea name="" class="textarea-edit" rows="" cols="" id="execution"><?= !empty($Lawsuit['execution'])?$Lawsuit['execution']:'';?></textarea>
                    </td>
                </tr>
                <tr>
                    <td>法&nbsp;&nbsp;院</td>
                    <td>
                        <textarea name="" rows="" class="textarea-edit" cols="" id="court"><?= !empty($Lawsuit['court'])?$Lawsuit['court']:'';?></textarea>
                    </td>
                </tr>
                <tr>
                    <td>列失信</td>
                    <td>
                        <textarea name="" rows="" class="textarea-edit" placeholder="可以列失信限高的理由（人大代表、政协委员、上市公司高管等）" cols="" id="block"><?= !empty($Lawsuit['block'])?$Lawsuit['block']:'';?></textarea>
                    </td>
                </tr>
            </table>
            <div class="cancelInConfirm clearfix">
                <input id="ajaxLawsuit" class="cancelInConfirmActive" type="button" value="保存" />
                <input id='cancelSiFa' type="button" value="取消" />
            </div>
        </form>

    </div>
</div>
<!-- textarea 高度设置对比div -->
	<div style="max-height: 1px; overflow: hidden;">
		<div id="d1" style="visibility:hidden;min-height: 80px;"></div>
	</div>
<script>
    $(function () {
        var judgement = ''; //
        var execution = ''; //
        var court = ''; //
        var block = ''; //
        var data = {};
        $("#ajaxLawsuit").click(function () {
            judgement = $("#judgement").val();
            execution = $("#execution").val();
            court = $("#court").val();
            block = $("#block").val();
            data = {
                'judgement':judgement,
                'execution':execution,
                'court':court,
                'block':block,
                'project_id':project_id,
                'package_id':package_id,
            }
            $.post('/project/ajax-save-lawsuit-project',{'data':data},function (res) {
                if (res){
                    layer.msg("更新成功");
                    siFaW()
                }else{
                    layer.msg("无数据更新，更新失败");
                }
            })
        })
        //-----------------渲染无编辑页面--------------------
        function siFaW() {
            $.get('/project/get-mortgage-view',{'project_id':project_id,'postion':2},function (res) {
                $(".suSongXinXiDOM").children().remove();
                $(".suSongXinXiDOM").html(res);
            })
        }
        //---取消按钮
        $("#cancelSiFa").click(function () {
            $.post('/project/ajax-un-lock',{'postion':4,'project_id':project_id},function (res) {
                var JSONData = JSON.parse(res)
                if (JSONData.code == 200){
                    layer.msg(JSONData.message);
                }else{
                    layer.msg(JSONData.message);
                }
            });
            $(".judicialEdit").hide();
            $(".judicialW").show();
        })
        	// textarea 高度展示问题
	    $(".textarea-edit").keyup(function(){
	           console.log(111111111);
	      var val = $(this).val();
	      $("#d1").html("<pre>" +val+" "+"</pre>");
	      var h = $("#d1").height() ;
	      $(this).height(h);
	    });
    })
</script>